<?php
if(!isset($_SESSION)){
    session_start();
}
header('content-type:text/html;charset:utf8');
if(!isset($_SESSION["username"])&&!isset($_SESSION["password"])){
    echo "<script>alert('禁止非法从地址栏访问!');window.location.href='../view/login.php';</script>";
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>动物管理系统</title>
    <meta name="keywords" content="Bootstrap、动物管理系统、响应式布局、小白鼠管理" />
    <meta name="author" content="Binpeng Liu Hangzhou Normal University Software enginerring 121"  />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="assets/css/font-awesome.min.css" />
    <link rel="stylesheet" href="assets/css/fontFamily.css" />
    <link rel="stylesheet" href="assets/css/ace.min.css" />
    <link rel="stylesheet" href="assets/css/ace-rtl.min.css" />
    <link rel="stylesheet" href="assets/css/ace-skins.min.css" />
    <script src="assets/js/ace-extra.min.js"></script>
    <script type="text/javascript" src="../test/jquery-1.9.1.min.js"></script>
    <script language="javascript">
        function quit(){
            window.location.href="main.php";
        }
    </script>
    <script type="text/javascript">
        function modify(){
            var obj=document.getElementsByName('para');
            var s='';
            for(var i=0; i<obj.length; i++){
                if(obj[i].checked) s+=obj[i].value;
            }
            if(s==''){
                alert('你还没有选择任何内容！');
            }
        }
    </script>
    <script type="text/javascript">
        <!--
        function check(button){
            //执行删除行的操作
            var index  = -1;

            for(var i=0; i<fm.but.length ;i++){
                if(fm.but[i] == button){
                    index = i;
                    break;
                }
            }
            var val=fm.two[index].value;
            alert(val);

        }
        //-->
    </script>
</head>
<body>
<div class="navbar navbar-default" id="navbar">
    <script type="text/javascript">
        try{ace.settings.check('navbar' , 'fixed')}catch(e){}
    </script>

    <div class="navbar-container" id="navbar-container">
        <div class="navbar-header pull-left">
            <a href="#" class="navbar-brand">
                <small>
                    <i class="icon-leaf"></i>
                    动物管理系统
                </small>
            </a><!-- /.brand -->
        </div><!-- /.navbar-header -->

        <div class="navbar-header pull-right" role="navigation">
            <ul class="nav ace-nav">


                <li class="purple">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                        <i class="icon-bell-alt icon-animated-bell"></i>
                        <span class="badge badge-important">8</span>
                    </a>

                    <ul class="pull-right dropdown-navbar navbar-pink dropdown-menu dropdown-caret dropdown-close">
                        <li class="dropdown-header">
                            <i class="icon-warning-sign"></i>
                            8条通知
                        </li>

                        <li>
                            <a href="#">
                                <div class="clearfix">
											<span class="pull-left">
												<i class="btn btn-xs no-hover btn-pink icon-comment"></i>
												新闻评论
											</span>
                                    <span class="pull-right badge badge-info">+12</span>
                                </div>
                            </a>
                        </li>
                    </ul>
                </li>

                <li class="light-blue">
                    <a data-toggle="dropdown" href="#" class="dropdown-toggle">
                        <img class="nav-user-photo" src="assets/avatars/user.jpg" alt="Jason's Photo" />
								<span class="user-info">
									<small>欢迎光临,</small>
                                    <?php
                                    echo $_SESSION["username"];
                                    ?>
								</span>

                        <i class="icon-caret-down"></i>
                    </a>

                    <ul class="user-menu pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
                        <li class="divider"></li>

                        <li>
                            <a href="main.php">
                                <i class="icon-off"></i>
                                退出
                            </a>
                        </li>
                    </ul>
                </li>
            </ul><!-- /.ace-nav -->
        </div><!-- /.navbar-header -->
    </div><!-- /.container -->
</div>

<div class="main-container" id="main-container">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>

    <div class="main-container-inner">
        <a class="menu-toggler" id="menu-toggler" href="#">
            <span class="menu-text"></span>
        </a>

        <div class="sidebar" id="sidebar">
            <script type="text/javascript">
                try{ace.settings.check('sidebar' , 'fixed')}catch(e){}
            </script>

            <div class="sidebar-shortcuts" id="sidebar-shortcuts">
                <div class="sidebar-shortcuts-large" id="sidebar-shortcuts-large">
                    <button class="btn btn-success">
                        <i class="icon-signal"></i>
                    </button>

                    <button class="btn btn-info">
                        <i class="icon-pencil"></i>
                    </button>

                    <button class="btn btn-warning">
                        <i class="icon-group"></i>
                    </button>

                    <button class="btn btn-danger">
                        <i class="icon-cogs"></i>
                    </button>
                </div>

                <div class="sidebar-shortcuts-mini" id="sidebar-shortcuts-mini">
                    <span class="btn btn-success"></span>

                    <span class="btn btn-info"></span>

                    <span class="btn btn-warning"></span>

                    <span class="btn btn-danger"></span>
                </div>
            </div><!-- #sidebar-shortcuts -->

            <ul class="nav nav-list">
                <li class="active">
                    <a href="cageApply.php">
                        <i class="icon-edit"></i>
                        <span class="menu-text"> 新笼位申请 </span>
                    </a>
                </li>

                <li>
                    <a href="main.php">
                        <i class="icon-text-width"></i>
                        <span class="menu-text">已启用笼位查询 </span>
                    </a>
                </li>

                <li>
                    <a href="#" class="dropdown-toggle">
                        <i class="icon-desktop"></i>
                        <span class="menu-text"> 申请状态笼位查询 </span>

                        <b class="arrow icon-angle-down"></b>
                    </a>

                </li>

                <li>
                    <a href="#" class="dropdown-toggle">
                        <i class="icon-list"></i>
                        <span class="menu-text"> 小鼠信息检索 </span>

                        <b class="arrow icon-angle-down"></b>
                    </a>
                </li>
                <li>
                    <a href="profile.php" class="dropdown-toggle">
                        <i class="icon-user"></i>
                        <span class="menu-text">个人资料 </span>

                        <b class="arrow icon-angle-down"></b>
                    </a>
                </li>
            </ul><!-- /.nav-list -->

            <div class="sidebar-collapse" id="sidebar-collapse">
                <i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
            </div>

            <script type="text/javascript">
                try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
            </script>
        </div>

        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <script type="text/javascript">
                    try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
                </script>

                <ul class="breadcrumb">
                    <li>
                        <i class="icon-home home-icon"></i>
                        <a href="#">首页</a>
                    </li>
                    <li class="active">新笼位申请</li>
                </ul><!-- .breadcrumb -->
            </div>

            <div class="page-content">
                <div class="page-header">
                    <h1>
                        新笼位申请
                        <small>
                            <i class="icon-double-angle-right"></i>
                            提交小鼠信息
                        </small>
                    </h1>
                </div><!-- /.page-header -->

                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="col-xs-12">
                            <div class="table-responsive">
                                <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th class="center">
                                            <label>
                                                <input type="checkbox" class="ace" />
                                                <span class="lbl"></span>
                                            </label>
                                        </th>
                                        <th class="center">编号</th>
                                        <th class="center">耳标</th>
                                        <th class="center">动物名称</th>
                                        <th class="hidden-480 center">背景品系</th>

                                        <th class="center">
                                            <i class="icon-time bigger-110 hidden-480"></i>
                                            基因类别
                                        </th>
                                        <th class="hidden-480 center">毛色类别</th>
                                        <th hidden="true">申请人</th>
                                    </tr>
                                    </thead>

                                    <tbody>


                                    <tr>
                                        <?php
                                        error_reporting(0);
                                        require_once('../model/PdoMySQL.class.php');
                                        require_once('../model/config.php');
                                        header("Content-Type: text/html;charset=utf-8");
                                        $table="cageapply";
                                        $PdoMySQL=new PdoMySQL();
                                        $sql="select * from mouseapply  where  cageid = "
                                            + cageid + " order by id  asc";
                                        $row=$PdoMySQL->find($table,'status=0');
                                        if($row['gene']==1){
                                            $gene='纯合';

                                        }else if($row['gene']==2){
                                            $gene='杂合';
                                        }else{
                                            $gene='野生型';
                                        }
                                        if($row['furcolor']==1){
                                            $furcolor='黑色';

                                        }else if($row['furcolor']==2){
                                            $furcolor='白色';
                                        }else if($row['furcolor']==3){
                                            $furcolor='无毛';
                                        }else if($row['furcolor']==4){
                                            $furcolor='棕色';
                                        }
                                        else{
                                            $furcolor='其它';
                                        }

                                        echo '<td class="center">'.'<label>';
                                        echo '<input type="checkbox" class="ace"  />';
                                        echo '	<span class="lbl"></span>'.'</label>'.'</td>';
                                        echo '<td class="center">';
                                        echo '<a href="#">'.$row['id'].'</a></td>';
                                        echo '<input type="hidden"  name="alert" value="'.$row['erbiao'].'" />';
                                        echo '<td class="center">'.$row['erbiao'].'</td>';
                                        echo '<td class="center">'.$row['animalName'].'</td>';
                                        echo '<td class="hidden-480 center">'.$row['breed'].'</td>';
                                        echo '<td class="center">'.$gene.'</td>';
                                        echo '<td class="hidden-480 center">';
                                        echo '<span class="label label-sm label-success">'.$furcolor.'</span>';
                                        echo '</td>';
                                        ?>

                                    </tr>
                                    </tbody>
                                </table>
                            </div><!-- /.table-responsive -->
                        </div>
                        <form class="form-horizontal" role="form" name="form">
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1">当前序号</label>
                                <div class="col-sm-9">
                                    <input type="text" id="id"  name="id" class="col-xs-10 col-sm-5"   title="请顺序填写数字1~5"/>
                            <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">单一笼盒最大饲养量为5只。</span>
											</span>

                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-1">耳标</label>
                                <div class="col-sm-9">
                                    <input type="text" id="erbiao" name="erbiao" class="col-xs-10 col-sm-5" />
											<span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">填写耳标，让你的小鼠独一无二</span>
											</span>
                                </div>
                            </div>
                            <?php  echo '<input type="text" hidden="true" id="username" name="username" value="'.$_SESSION['loginuser'].'"/>'  ?>
                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-field-2">动物名称 </label>

                                <div class="col-sm-9">
                                    <input type="text" id="animalName" name="animalName" class="col-xs-10 col-sm-5" />
											<span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">请尽量标注完整，以方便检索和区分。
</span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" for="form-input-readonly">背景品系</label>

                                <div class="col-sm-9">
                                    <input  type="text" name="breed" id="breed" class="col-xs-10 col-sm-5"  />
											<span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">C57BL/6、BALB/c、ICR、裸鼠等。</span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right" >基因类别</label>

                                <div class="col-sm-9">
                                    <input  type="text" id="gene" name="gene" class="col-xs-10 col-sm-5"  />
											<span class="help-inline col-xs-12 col-sm-7">
								<span class="middle">纯合、杂合或野生型等。</span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group>
                                    <div class=col-sm-9">
                                <div class="radio">
                                    <label>
                                        <input  title="提供毛色信息将有助于提高我们的精细化管理水平。" type="radio" name="furcolor" id="furcolor" value="黑色" checked class="col-xs-10 col-sm-5">黑色</label><img src="../images/black.jpg" width="90" />
                                </div>
                            </div>
                            <div class=col-sm-9">
                                <div class="radio">
                                    <label>
                                        <input title="提供毛色信息将有助于提高我们的精细化管理水平。"  type="radio" name="furcolor" id="furcolor" value="白色" class="col-xs-10 col-sm-5">白色</label><img src="../images/white.jpg" width="90" />
                                </div>
                            </div>
                            <div class=col-sm-9">
                                <div class="radio ">
                                    <label>
                                        <input title="提供毛色信息将有助于提高我们的精细化管理水平。" type="radio" name="furcolor"  id="furcolor" value="无毛" class="col-xs-10 col-sm-5">无毛</label><img src="../images/null.jpg" width="80" />
                                </div>
                            </div>
                            <div class=col-sm-9">
                                <div class="radio ">
                                    <label>
                                        <input title="提供毛色信息将有助于提高我们的精细化管理水平。"  type="radio" name="furcolor" id="furcolor"  value="棕色" class="col-xs-10 col-sm-5">棕色</label><img src="../images/brown.jpg" width="80" />
                                </div>
                            </div>
                            <div class=col-sm-9">
                                <div class="radio ">
                                    <label>
                                        <input title="提供毛色信息将有助于提高我们的精细化管理水平。"  type="radio" name="furcolor" id="furcolor" value="其它" class="col-xs-10 col-sm-5">其它</label>
                                </div>
                            </div>
                    </div>
                    <div class="space-4"></div>
                    <div class="space-4"></div>
                    <div class="space-4"></div>
                    <div class="clearfix form-actions">
                        <div class="col-md-offset-3 col-md-9">
                            <!--											<button class="btn btn-info" type="button" id="applypost">-->
                            <button class="btn btn-info" type="button" id="post" onmouseover="check()">

                                <i class="icon-ok bigger-110"></i>
                                提交
                            </button>
                            <button class="btn btn-success" type="reset"  onclick="javascript:window.location.reload();">
                                <i class="icon-undo bigger-110"></i>
                                新增
                            </button>

                            <!-- 	   echo '<a  class="btn btn-warning"  role="button" href="edit.php?id='.$row['id'].'" onClick="modify();" >'; -->

                            <?php
                            echo '<a  class="btn btn-warning"  role="button" href="applymodify.php?erbiao='.$row['erbiao'].'" onClick="modify();" >';
                            echo  '<i class="icon-edit bigger-110">修改</i></a>';
                            ?>


                            <button class="btn btn-info" type="reset" id="applysave">
                                <i class="icon-save bigger-110"></i>
                                保存
                            </button>

                            <button class="btn btn-danger" type="reset" onClick="quit()">
                                <i class="icon-remove bigger-110"></i>
                                退出
                            </button>

                        </div>
                    </div>
                    <p id="saveResult" style="color:#F00"></p>
                    <p id="postResult" style="color:#F00"></p>
                    <script>
                        var kind;//全局变量
                        function check(){
                            var obj = document.getElementsByName("type");

                            if(obj[i].checked){
                                var b=obj[i].value;

                                return b;
                            }
                        }
                        kind=check();

                    </script>

                    <script>

                        document.getElementById("post").onclick = function() {
                            alert(111);
                            alert(kind);
                            var request = new XMLHttpRequest();
                            request.open("GET", "post.php");
                            var data = "order=" + document.getElementById("order").value
                                + "&name=" + document.getElementById("name").value
                                + "&breed=" + document.getElementById("breed").value
                                + "&gene=" + document.getElementById("gene").value
                                +"&type"+kind;
                            request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                            request.send(data);
                            request.onreadystatechange = function() {
                                if (request.readyState===4) {
                                    if (request.status===200) {
                                        document.getElementById("createResult").innerHTML = request.responseText;
                                    } else {
                                        alert("发生错误：" + request.status);
                                    }
                                }
                            }
                        }
                    </script>
                    <script>
                        document.getElementById("applypost").onclick = function() {
                            var request = new XMLHttpRequest();
                            request.open("POST", "../controller/applypost.php");
                            var data = "id="+document.getElementById("id").value
                                +"&erbiao="+document.getElementById("erbiao").value
                                +"&username=" + document.getElementById("username").value
                                +"&animalName=" + document.getElementById("animalName").value
                                + "&breed=" + document.getElementById("breed").value
                                + "&gene=" + document.getElementById("gene").value
                                +"&furcolor="+document.form.furcolor.value;
                            request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                            request.send(data);
                            request.onreadystatechange = function() {
                                if (request.readyState===4) {
                                    if (request.status===200) {
                                        document.getElementById("saveResult").innerHTML = request.responseText;
                                        window.location.reload();
                                    } else {
                                        alert("发生错误：" + request.status);
                                    }
                                }
                            }
                        }
                    </script>
                    <script>
                        document.getElementById("applysave").onclick = function() {
                            var request = new XMLHttpRequest();
                            request.open("POST", "../controller/applysave.php");
                            var data = "id="+document.getElementById("id").value
                                +"&erbiao="+document.getElementById("erbiao").value
                                +"&username=" + document.getElementById("username").value
                                +"&animalName=" + document.getElementById("animalName").value
                                + "&breed=" + document.getElementById("breed").value
                                + "&gene=" + document.getElementById("gene").value
                                +"&furcolor="+document.form.furcolor.value;
                            request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                            request.send(data);
                            request.onreadystatechange = function() {
                                if (request.readyState===4) {
                                    if (request.status===200) {
                                        document.open();		//document.open->document.getelementbyid->document.close()实现当调用ajax后整个页面刷新一次
                                        document.getElementById("postResult").innerHTML = request.responseText;
                                        document.close();
                                    } else {
                                        alert("发生错误：" + request.status);
                                    }
                                }
                            }
                        }
                    </script>
                </div><!-- /row -->
            </div><!-- PAGE CONTENT ENDS -->
        </div><!-- /.col -->
    </div><!-- /.row -->
</div><!-- /.page-content -->
</div><!-- /.main-content -->

<div class="ace-settings-container" id="ace-settings-container">
    <div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
        <i class="icon-cog bigger-150"></i>
    </div>

    <div class="ace-settings-box" id="ace-settings-box">
        <div>
            <div class="pull-left">
                <select id="skin-colorpicker" class="hide">
                    <option data-skin="default" value="#438EB9">#438EB9</option>
                    <option data-skin="skin-1" value="#222A2D">#222A2D</option>
                    <option data-skin="skin-2" value="#C6487E">#C6487E</option>
                    <option data-skin="skin-3" value="#D0D0D0">#D0D0D0</option>
                </select>
            </div>
            <span>&nbsp; Choose Skin</span>
        </div>

        <div>
            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-navbar" />
            <label class="lbl" for="ace-settings-navbar"> Fixed Navbar</label>
        </div>

        <div>
            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-sidebar" />
            <label class="lbl" for="ace-settings-sidebar"> Fixed Sidebar</label>
        </div>

        <div>
            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-breadcrumbs" />
            <label class="lbl" for="ace-settings-breadcrumbs"> Fixed Breadcrumbs</label>
        </div>

        <div>
            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-rtl" />
            <label class="lbl" for="ace-settings-rtl"> Right To Left (rtl)</label>
        </div>

        <div>
            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container" />
            <label class="lbl" for="ace-settings-add-container">
                Inside
                <b>.container</b>
            </label>
        </div>
    </div>
</div><!-- /#ace-settings-container -->
</div><!-- /.main-container-inner -->

<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="icon-double-angle-up icon-only bigger-110"></i>
</a>
</div><!-- /.main-container -->

<!-- basic scripts -->

<!--[if !IE]> -->

<script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>

<!-- <![endif]-->

<!--[if IE]>
<script src="http://cdn.bootcss.com/jquery/2.0.3/jquery.min.js"></script>
<![endif]-->

<!--[if !IE]> -->

<script type="text/javascript">
    window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
</script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/typeahead-bs2.min.js"></script>

<script src="assets/js/jquery-ui-1.10.3.custom.min.js"></script>
<script src="assets/js/jquery.ui.touch-punch.min.js"></script>
<script src="assets/js/chosen.jquery.min.js"></script>
<script src="assets/js/fuelux/fuelux.spinner.min.js"></script>
<script src="assets/js/date-time/bootstrap-datepicker.min.js"></script>
<script src="assets/js/date-time/bootstrap-timepicker.min.js"></script>
<script src="assets/js/date-time/moment.min.js"></script>
<script src="assets/js/date-time/daterangepicker.min.js"></script>
<script src="assets/js/bootstrap-colorpicker.min.js"></script>
<script src="assets/js/jquery.knob.min.js"></script>
<script src="assets/js/jquery.autosize.min.js"></script>
<script src="assets/js/jquery.inputlimiter.1.3.1.min.js"></script>
<script src="assets/js/jquery.maskedinput.min.js"></script>
<script src="assets/js/bootstrap-tag.min.js"></script>

<!-- ace scripts -->

<script src="assets/js/ace-elements.min.js"></script>
<script src="assets/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">
    jQuery(function($) {
        $('#id-disable-check').on('click', function() {
            var inp = $('#form-input-readonly').get(0);
            if(inp.hasAttribute('disabled')) {
                inp.setAttribute('readonly' , 'true');
                inp.removeAttribute('disabled');
                inp.value="This text field is readonly!";
            }
            else {
                inp.setAttribute('disabled' , 'disabled');
                inp.removeAttribute('readonly');
                inp.value="This text field is disabled!";
            }
        });


        $(".chosen-select").chosen();
        $('#chosen-multiple-style').on('click', function(e){
            var target = $(e.target).find('input[type=radio]');
            var which = parseInt(target.val());
            if(which == 2) $('#form-field-select-4').addClass('tag-input-style');
            else $('#form-field-select-4').removeClass('tag-input-style');
        });


        $('[data-rel=tooltip]').tooltip({container:'body'});
        $('[data-rel=popover]').popover({container:'body'});

        $('textarea[class*=autosize]').autosize({append: "\n"});
        $('textarea.limited').inputlimiter({
            remText: '%n character%s remaining...',
            limitText: 'max allowed : %n.'
        });

        $.mask.definitions['~']='[+-]';
        $('.input-mask-date').mask('99/99/9999');
        $('.input-mask-phone').mask('(999) 999-9999');
        $('.input-mask-eyescript').mask('~9.99 ~9.99 999');
        $(".input-mask-product").mask("a*-999-a999",{placeholder:" ",completed:function(){alert("You typed the following: "+this.val());}});



        $( "#input-size-slider" ).css('width','200px').slider({
            value:1,
            range: "min",
            min: 1,
            max: 8,
            step: 1,
            slide: function( event, ui ) {
                var sizing = ['', 'input-sm', 'input-lg', 'input-mini', 'input-small', 'input-medium', 'input-large', 'input-xlarge', 'input-xxlarge'];
                var val = parseInt(ui.value);
                $('#form-field-4').attr('class', sizing[val]).val('.'+sizing[val]);
            }
        });

        $( "#input-span-slider" ).slider({
            value:1,
            range: "min",
            min: 1,
            max: 12,
            step: 1,
            slide: function( event, ui ) {
                var val = parseInt(ui.value);
                $('#form-field-5').attr('class', 'col-xs-'+val).val('.col-xs-'+val);
            }
        });


        $( "#slider-range" ).css('height','200px').slider({
            orientation: "vertical",
            range: true,
            min: 0,
            max: 100,
            values: [ 17, 67 ],
            slide: function( event, ui ) {
                var val = ui.values[$(ui.handle).index()-1]+"";

                if(! ui.handle.firstChild ) {
                    $(ui.handle).append("<div class='tooltip right in' style='display:none;left:16px;top:-6px;'><div class='tooltip-arrow'></div><div class='tooltip-inner'></div></div>");
                }
                $(ui.handle.firstChild).show().children().eq(1).text(val);
            }
        }).find('a').on('blur', function(){
            $(this.firstChild).hide();
        });

        $( "#slider-range-max" ).slider({
            range: "max",
            min: 1,
            max: 10,
            value: 2
        });

        $( "#eq > span" ).css({width:'90%', 'float':'left', margin:'15px'}).each(function() {
            // read initial values from markup and remove that
            var value = parseInt( $( this ).text(), 10 );
            $( this ).empty().slider({
                value: value,
                range: "min",
                animate: true

            });
        });


        $('#id-input-file-1 , #id-input-file-2').ace_file_input({
            no_file:'No File ...',
            btn_choose:'Choose',
            btn_change:'Change',
            droppable:false,
            onchange:null,
            thumbnail:false //| true | large
            //whitelist:'gif|png|jpg|jpeg'
            //blacklist:'exe|php'
            //onchange:''
            //
        });

        $('#id-input-file-3').ace_file_input({
            style:'well',
            btn_choose:'Drop files here or click to choose',
            btn_change:null,
            no_icon:'icon-cloud-upload',
            droppable:true,
            thumbnail:'small'//large | fit
            //,icon_remove:null//set null, to hide remove/reset button
            /**,before_change:function(files, dropped) {
						//Check an example below
						//or examples/file-upload.html
						return true;
					}*/
            /**,before_remove : function() {
						return true;
					}*/
            ,
            preview_error : function(filename, error_code) {
                //name of the file that failed
                //error_code values
                //1 = 'FILE_LOAD_FAILED',
                //2 = 'IMAGE_LOAD_FAILED',
                //3 = 'THUMBNAIL_FAILED'
                //alert(error_code);
            }

        }).on('change', function(){
            //console.log($(this).data('ace_input_files'));
            //console.log($(this).data('ace_input_method'));
        });


        //dynamically change allowed formats by changing before_change callback function
        $('#id-file-format').removeAttr('checked').on('change', function() {
            var before_change
            var btn_choose
            var no_icon
            if(this.checked) {
                btn_choose = "Drop images here or click to choose";
                no_icon = "icon-picture";
                before_change = function(files, dropped) {
                    var allowed_files = [];
                    for(var i = 0 ; i < files.length; i++) {
                        var file = files[i];
                        if(typeof file === "string") {
                            //IE8 and browsers that don't support File Object
                            if(! (/\.(jpe?g|png|gif|bmp)$/i).test(file) ) return false;
                        }
                        else {
                            var type = $.trim(file.type);
                            if( ( type.length > 0 && ! (/^image\/(jpe?g|png|gif|bmp)$/i).test(type) )
                                || ( type.length == 0 && ! (/\.(jpe?g|png|gif|bmp)$/i).test(file.name) )//for android's default browser which gives an empty string for file.type
                            ) continue;//not an image so don't keep this file
                        }

                        allowed_files.push(file);
                    }
                    if(allowed_files.length == 0) return false;

                    return allowed_files;
                }
            }
            else {
                btn_choose = "Drop files here or click to choose";
                no_icon = "icon-cloud-upload";
                before_change = function(files, dropped) {
                    return files;
                }
            }
            var file_input = $('#id-input-file-3');
            file_input.ace_file_input('update_settings', {'before_change':before_change, 'btn_choose': btn_choose, 'no_icon':no_icon})
            file_input.ace_file_input('reset_input');
        });




        $('#spinner1').ace_spinner({value:0,min:0,max:200,step:10, btn_up_class:'btn-info' , btn_down_class:'btn-info'})
            .on('change', function(){
                //alert(this.value)
            });
        $('#spinner2').ace_spinner({value:0,min:0,max:10000,step:100, touch_spinner: true, icon_up:'icon-caret-up', icon_down:'icon-caret-down'});
        $('#spinner3').ace_spinner({value:0,min:-100,max:100,step:10, on_sides: true, icon_up:'icon-plus smaller-75', icon_down:'icon-minus smaller-75', btn_up_class:'btn-success' , btn_down_class:'btn-danger'});



        $('.date-picker').datepicker({autoclose:true}).next().on(ace.click_event, function(){
            $(this).prev().focus();
        });
        $('input[name=date-range-picker]').daterangepicker().prev().on(ace.click_event, function(){
            $(this).next().focus();
        });

        $('#timepicker1').timepicker({
            minuteStep: 1,
            showSeconds: true,
            showMeridian: false
        }).next().on(ace.click_event, function(){
            $(this).prev().focus();
        });

        $('#colorpicker1').colorpicker();
        $('#simple-colorpicker-1').ace_colorpicker();


        $(".knob").knob();


        //we could just set the data-provide="tag" of the element inside HTML, but IE8 fails!
        var tag_input = $('#form-field-tags');
        if(! ( /msie\s*(8|7|6)/.test(navigator.userAgent.toLowerCase())) )
        {
            tag_input.tag(
                {
                    placeholder:tag_input.attr('placeholder'),
                    //enable typeahead by specifying the source array
                    source: ace.variable_US_STATES,//defined in ace.js >> ace.enable_search_ahead
                }
            );
        }
        else {
            //display a textarea for old IE, because it doesn't support this plugin or another one I tried!
            tag_input.after('<textarea id="'+tag_input.attr('id')+'" name="'+tag_input.attr('name')+'" rows="3">'+tag_input.val()+'</textarea>').remove();
            //$('#form-field-tags').autosize({append: "\n"});
        }




        /////////
        $('#modal-form input[type=file]').ace_file_input({
            style:'well',
            btn_choose:'Drop files here or click to choose',
            btn_change:null,
            no_icon:'icon-cloud-upload',
            droppable:true,
            thumbnail:'large'
        })

        //chosen plugin inside a modal will have a zero width because the select element is originally hidden
        //and its width cannot be determined.
        //so we set the width after modal is show
        $('#modal-form').on('shown.bs.modal', function () {
            $(this).find('.chosen-container').each(function(){
                $(this).find('a:first-child').css('width' , '210px');
                $(this).find('.chosen-drop').css('width' , '210px');
                $(this).find('.chosen-search input').css('width' , '200px');
            });
        })
        /**
         //or you can activate the chosen plugin after modal is shown
         //this way select element becomes visible with dimensions and chosen works as expected
         $('#modal-form').on('shown', function () {
					$(this).find('.modal-chosen').chosen();
				})
         */

    });
</script>
<div style="display:none"><script src="assets/js/stat.js"></script></div>
</body>
</html>
